<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">

    <title>Starter Template for Bootstrap</title>

    <link href="./dist/css/bootstrap.min.css" rel="stylesheet">
    <script type="text/javascript" src="./dist/js/jquery-1.7.2.js"></script>
    <style type="text/css">
      .panel-body a,input,button{
        float: right;
        margin-left: 10px;
      }
      .yu{
        line-height: 30px;
      }
    </style>

  </head>
  <body>
  <div style="widht:100%; height:50px; background-color: #00AFC7"> 
  </div> 
  <div class="container">

    <div class="panel-body">
       <?php if(isset($_SESSION['username'])){ ?>
          <div class="navbar-form navbar-right">
            <span class='yu'>欢迎<?php echo $_SESSION['username'] ?></span>
            <a href="./tu.php" class="btn btn-success" onclick="javascript:if(confirm('确定要退出吗？')){return true;}return false">退出</a>
          </div>
       <?php } else{ ?> 
          <a href="./zc.php" class="btn btn-primary" >注册</a> 
          <form action="./dbl.php" method="POST">
            <button class="btn btn-default" type="submit">登录</button>
            <input type="password" name="password">
            <input type="text" name="username">
          </form>
       <?php } ?>
    </div>    
    <div class="panel panel-default">
      <?php foreach ($db as $k => $v) {?>
          <div class="panel-heading">
            <?php echo $v['username'] ?>(<?php echo date('Y-m-d H:i:s',$v['create_time']) ?>)
            <a href="./erase.php?id=<?php echo $k ?>" class="btn btn-danger" onclick="javascript:if(confirm('确定要删除此信息吗？')){return true;}return false">删除</a>

            <a href="./editing.php?id=<?php echo $k ?>" class="btn btn-primary" >编辑</a> 
          </div> 
          <div class="panel-body">
            <?php echo $v['content'] ?>
          </div>
      <?php } ?> 
    </div>
  
    <form action="./abb.php" method="POST">
      <div class="row">
        <div class="col-lg-2">
          <div class="input-group">
            <input type="hidden" class="form-control" value="<?php if (isset($_SESSION['username'])) {echo $_SESSION['username'];} ?>" name="username" >
            <span href=""><?php if (isset($_SESSION['username'])) { echo "欢迎用户".$_SESSION['username'];}else{echo "请登录再留言";} ?></span>
            <span class="input-group-btn">
             <button class="btn btn-default" type="submit">留言</button>
            </span>
          </div>
        </div>
      </div>
      <textarea style="width: 60%;" name="content"></textarea>
    </form>
  </div>  
  </body>
</html>